/**   
 * Copyright © 2018 YouoTech Of China,All Right Reserved.
 * 功能描述：
 * @Package: com.youotech.fileManagementSys.until 
 * @author: GuanRuming Email:guanruming@youotech.com   
 * @date: 2018年6月27日 上午9:49:31 
 */
package com.ctcemti.mdm.common.util;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**   
* Copyright © 2018 YouoTech Of China,All Right Reserved.
* @ClassName: PropertyUtil.java
* @Description: 读取jdbc配置文件内容
* @version: v1.0.0
* @date: 2018年6月27日 上午9:49:31
*
* Modification History:
* Date         Author          Version            Description
*---------------------------------------------------------*
* 2018年6月27日     Administrator           v1.0.0               修改原因
*/
public class PropertyUtil {
    private static Properties props;
    static{
        loadProps();
    }

    synchronized static private void loadProps(){
        props = new Properties();
        InputStream in = null;
        try {
            in = PropertyUtil.class.getClassLoader().getResourceAsStream("jdbc.properties");
            props.load(in);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if(null != in) {
                    in.close();
                }
            } catch (IOException e) {
            	e.printStackTrace();
            }
        }
    }

    public static String getProperty(String key){
        if(null == props) {
            loadProps();
        }
        return props.getProperty(key);
    }

    public static String getProperty(String key, String defaultValue) {
        if(null == props) {
            loadProps();
        }
        return props.getProperty(key, defaultValue);
    }
}
